package com.cskaoyan.shopping.controller;

import com.cskaoyan.mall.commons.result.ResponseData;
import com.cskaoyan.mall.commons.result.ResponseUtil;
import com.cskaoyan.mall.constant.ShoppingRetCode;
import com.cskaoyan.shopping.dto.ShoppingCategoriesResponse;
import com.cskaoyan.shopping.service.ShoppingCategoriesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 类说明
 *
 * @author zhangfuqiang
 * @date 2022/5/19
 */
@RestController
public class ShoppingCategoriesController {

    @Autowired
    ShoppingCategoriesService shoppingCategoriesService;

    //http://localhost:8102/shopping/categories
    @GetMapping("/shopping/categories")
    public ResponseData getShoppingCategories() {

        // 根据业务逻辑处理请求
        ShoppingCategoriesResponse response = shoppingCategoriesService.getShoppingCategories();

        if (ShoppingRetCode.SUCCESS.getCode().equals(response.getCode())) {
            // 业务方法调用成功
            return new ResponseUtil().setData(response.getResponse());
        }

        // 业务方法执行失败
        return new ResponseUtil().setErrorMsg(response.getMsg());
    }
}
